STOR 437- Create API for vsphere CSI topology configuration#1271
Conversation
|
Hello @gnufied! Some important instructions when contributing to openshift/api: For merging purposes, this repository follows the no-Feature-Freeze process which means that in addition to the standard
OR
Who should apply these qe/docs/px labels?
|
|
/retest |
6ee97f8 to
c275e8f
Compare
| // +kubebuilder:validation:Required | ||
| // +unionDiscriminator | ||
| // +required | ||
| DriverName CSIDriverName `json:"driverName"` |
There was a problem hiding this comment.
CR.Name must be the CSI driver name, so field will duplicate that information?
Also, CR.Spec.DriverConfig.DriverName seems a bit verbose/redundant.
There was a problem hiding this comment.
^ this is a good point IMO, I don't really understand the purpose of the new DriverName field.
There was a problem hiding this comment.
yeah I am going to rename it. But we do need a field here as a union discriminator which will basically make it obvious that if driverName: vsphere.vmware.com then - only vsphere will be set.
There was a problem hiding this comment.
I am torn about renaming driverName to Name. Elsewhere in OCP docs, union discriminators are called Type - if we do that, then we probably have to define a new enum.
There was a problem hiding this comment.
Ah, I don't have a strong preference on renaming the field, I think DriverName is fine. I just didn't understand the purpose, but that doc on discriminated unions explains it.
|
/assign @JoelSpeed @deads2k |
| // DriverConfig field can be used to optionally specify | ||
| // driver specific configuration. | ||
| // If this field is nil, platform chosen default configuration | ||
| // will be applied. | ||
| // +kubebuilder:validation:Optional | ||
| // +optional | ||
| DriverConfig *CSIDriverConfigSpec `json:"driverConfig,omitempty"` |
There was a problem hiding this comment.
Few nits on this:
- The first word should match the json tag
- We should use the standard wording that other APIs use for when this is optional
- You only need one optional tag, we prefer
+optional - You shouldn't use a pointer here unless you have a good reason to do so, do you need a pointer?
| // DriverConfig field can be used to optionally specify | |
| // driver specific configuration. | |
| // If this field is nil, platform chosen default configuration | |
| // will be applied. | |
| // +kubebuilder:validation:Optional | |
| // +optional | |
| DriverConfig *CSIDriverConfigSpec `json:"driverConfig,omitempty"` | |
| // driverConfig can be used to specify platform specific driver configuration. | |
| // When omitted, this means no opinion and the platform is left to choose reasonable | |
| // defaults. These defaults are subject to change over time. | |
| // +optional | |
| DriverConfig CSIDriverConfigSpec `json:"driverConfig,omitempty"` |
There was a problem hiding this comment.
I was reading about API conventions and although I have accepted this suggestion, one of the things which I find sometimes problematic is - CSIDriverConfigSpec says DriverName is a required field and hence by that definition - an empty CSIDriverConfigSpec isn't a valid object because DriverName is not set. I know on the wire, if field is empty - it is entirely omitted but I think that after deserializing we basically have a GO object that is essentially invalid and does not conform to schema it defines itself, which is weird.
So I think for union types which have a required union discriminator I think that a nil pointer is only sensible default if users don't want to specify one.
There was a problem hiding this comment.
It's a trade off we have decide to make for the discoverability benefits. But yes, you need to teach your controller to handle the empty DriverConfig. It shouldn't be too difficult and isn't dissimilar to the nil check you'd have to otherwise do
emptyConfig := operatorv1.CSIDriverConfigSpec{}
if spec.DriverConfig == emptyConfig {
// No driver config was specified
return nil
}
| // TopologyCategories indicates categories with which | ||
| // vcenter resources as hostcluster or datacenter were tagged with. |
There was a problem hiding this comment.
Can you clarify what this means? It doesn't make sense to me, do you mean resources such as?
| // If unspecified CSI driver configuration will default to configuration | ||
| // specified in cluster configuration. |
There was a problem hiding this comment.
Where does this configuration live? On the Infrastructure object?
There was a problem hiding this comment.
Yes - basically what @jcpowermac is proposing in his enhancement.
There was a problem hiding this comment.
Ok, I'd expect the comment here to mention that it's on the Infrastructure object, gives user a hint as to where they can find the defaults
| // driverName indicates which CSI driver should be installed. | ||
| // +kubebuilder:validation:Required | ||
| // +unionDiscriminator | ||
| DriverName CSIDriverName `json:"driverName"` |
There was a problem hiding this comment.
This should be an enum, do we have a list of valid values for this?
There was a problem hiding this comment.
I have renamed this to CSIDriverType and defined a new enum. @bertinatto raised a concern that we were overloading CSIDriverName type which is used for defining driver name.
|
|
||
| // vsphere is used to configure the vsphere CSI driver. | ||
| // +optional | ||
| VSphere *VSphereCSIDriverConfigSpec `json:"vsphere,omitempty"` |
There was a problem hiding this comment.
What value must DriverName have for this configuration to be observed?
There was a problem hiding this comment.
Updated to reflect the values.
|
/lgtm |
1d1f84c to
5a99faf
Compare
JoelSpeed
left a comment
There was a problem hiding this comment.
I think we are pretty close, a few more comments
| // | ||
| // +kubebuilder:validation:Required | ||
| // +unionDiscriminator | ||
| DriverType CSIDriverType `json:"driverType"` |
There was a problem hiding this comment.
As this enum is expected over time, you need to add a developer note to explain what consumers should do when they observe an unknown value, there's typically two options there
| DriverType CSIDriverType `json:"driverType"` | |
| // --- | |
| // + Consumers should treat unknown values as a no-op || Consumers should treat unknown values as an error and stop processing. | |
| DriverType CSIDriverType `json:"driverType"` |
| // specified in Infrastructure object. If both Infrastructure object and | ||
| // ClusterCSIDriver specify topology - then values in Infrastructure object | ||
| // will take precedence. |
There was a problem hiding this comment.
Typically the closer object to the action (this resource) would take precedence, it seems odd to say the Infrastructure object will take precedence here, I would expect to reverse that.
Having the closer object allows whoever owns that specific component to override the global configuration should they need to.
Why are you suggesting it to be this way around?
There was a problem hiding this comment.
Currently its bit like you would expect ebs provisioner as default in a storageclass deployed on AWS cluster not ceph provisioner. One can deploy ceph on OCP AWS cluster sure but it requires bunch of manual configuration.
Similarly topology from Infrastructure object is guaranteed to be right and does not require any further manual configuration in vcenter, so we want to start with somewhat stricter definition of topologyCategories if Infra object already defines one.
Currently we are thinking - once Infra changes are merged, we will not allow setting these values at all by end users and any changes to ClusterCSIDriver topologies will be rejected by webhook, if Infra object already defines a topology(via failure-domains). I will update the wording here to be more clear on this.
But we also realize that, compute and storage topologies can have two different values - so we don't want to close the door completely on that option, so we may choose to relax this in a future version of OCP.
|
|
||
| // vsphere is used to configure the vsphere CSI driver. | ||
| // +optional | ||
| VSphere *VSphereCSIDriverConfigSpec `json:"vsphere,omitempty"` |
There was a problem hiding this comment.
If the right CSIDriverType is "VSphere", then this must be json:"vSphere
There was a problem hiding this comment.
Check the discriminated unions in the config v1 types and follow their patterns
|
@JoelSpeed PTAL. Dropped |
JoelSpeed
left a comment
There was a problem hiding this comment.
API looks good, have you tested it against a real cluster to make sure it behaves how you expect it should?
|
@JoelSpeed yep. The entire PR has been verified using linked changes into vmware-vpshere-csi-driver openshift/vmware-vsphere-csi-driver-operator#107 and it works as expected. |
|
/lgtm |
Update API to use latest guidelines, drop omitempty
2d7e29c to
269199d
Compare
|
@gnufied: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
/lgtm |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, dobsonj, gnufied, JoelSpeed, jsafrane The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/docs approved |
|
Since this is just an API change. /label docs-approved |
|
/label qe-approved |
xref https://issues.redhat.com/browse/STOR-437